package com.test;



import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.listener.ContainerProperties;

import java.util.HashMap;
import java.util.Map;

/**
 * 描述用途
 *
 * @author levikang0
 * @date 2020/01/10
 */

@Configuration
@ConfigurationProperties(prefix = "kafka")
@ConditionalOnClass(KafkaTemplate.class)
public class KafkaProperties {

    public static final String TRUE = "true";
    public static final String CLOSE_CONSUMER = "closeConsumer";


    private int concurrency = 1;
    private boolean batchListener = false;
    /**
     * 是否关闭kafka消费者自启动,默认开启
     * 本地启动可配置关闭
     */
    private boolean closeConsumer = false;
    private boolean laneOn = false;
    private boolean groupLaneOn = false;
    //强制消费基线
    private boolean forceConsumeMain = false;
    private long pollTimeout = 1000;
    private Long blockMaxTimeout;

    private String bootstrapServers;
    private String groupId;
    private Map<String, String> properties = new HashMap<>();
    private ContainerProperties.AckMode ackMode;

    public int getConcurrency() {
        return concurrency;
    }

    public void setConcurrency(int concurrency) {
        this.concurrency = concurrency;
    }

    public boolean isBatchListener() {
        return batchListener;
    }

    public void setBatchListener(boolean batchListener) {
        this.batchListener = batchListener;
    }

    public boolean isCloseConsumer() {
        return closeConsumer;
    }

    public void setCloseConsumer(boolean closeConsumer) {
        this.closeConsumer = closeConsumer;
    }

    public boolean isLaneOn() {
        return laneOn;
    }

    public void setLaneOn(boolean laneOn) {
        this.laneOn = laneOn;
    }

    public boolean isGroupLaneOn() {
        return groupLaneOn;
    }

    public void setGroupLaneOn(boolean groupLaneOn) {
        this.groupLaneOn = groupLaneOn;
    }

    public boolean isForceConsumeMain() {
        return forceConsumeMain;
    }

    public void setForceConsumeMain(boolean forceConsumeMain) {
        this.forceConsumeMain = forceConsumeMain;
    }

    public long getPollTimeout() {
        return pollTimeout;
    }

    public void setPollTimeout(long pollTimeout) {
        this.pollTimeout = pollTimeout;
    }

    public Long getBlockMaxTimeout() {
        return blockMaxTimeout;
    }

    public void setBlockMaxTimeout(Long blockMaxTimeout) {
        this.blockMaxTimeout = blockMaxTimeout;
    }

    public String getBootstrapServers() {
        return bootstrapServers;
    }

    public void setBootstrapServers(String bootstrapServers) {
        this.bootstrapServers = bootstrapServers;
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public Map<String, String> getProperties() {
        return properties;
    }

    public void setProperties(Map<String, String> properties) {
        this.properties = properties;
    }

    public ContainerProperties.AckMode getAckMode() {
        return ackMode;
    }

    public void setAckMode(ContainerProperties.AckMode ackMode) {
        this.ackMode = ackMode;
    }
}

